home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / STRERROR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  453 b   |  22 lines

  1. /* strerror.c  From TC Bible page 283  Use strerror to retrieve an error
  2. message corresponding to an error number */
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <io.h>
  7. #include <string.h>
  8. main()
  9. {
  10.     int handle=100;
  11.     char *errmsg;
  12.  
  13.     /* Generate an error condition by closing a file with a non-existant
  14.     file handle 100 */
  15.  
  16.     if(close(handle) == -1)
  17.     {
  18.         errmsg = strerror(errno);
  19.         printf("Error closing file: %s", errmsg);
  20.     }
  21.  
  22. }